<?php

namespace Api\Controller;

use Think\Controller;

/**
 * 接口抽象类
 * api安全通信
 * Class ApiController
 * @package Api\Controller
 */
abstract class ApiController extends Controller
{
    protected $query = array();

    protected function _initialize()
    {
        $query = I('request.');
        if ($query[C('API_KEY')]) {
            // 敏感参数解码
            $p = $query[C('API_KEY')];
            parse_str(think_decrypt($p), $this->query);
            foreach ($this->query as $k=>&$r){
                $_REQUEST[$k] = $r;
                $_GET[$k] = $r;
                $_POST[$k] = $r;
            }
        }
    }
}
